/// <summary>
/// method to check not only if a file is already open, but if the
/// but also if read and write permissions exist
/// </summary>
/// <param name="file">the file we wish to check</param>
/// <returns></returns>
public bool isFileOpenOrReadOnly(ref string file)
{
    try
    {
        //first make sure it's not a read only file
        if ((File.GetAttributes(file) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly)
        {
            //first we open the file with a FileStream
            using (FileStream stream = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None))
            {
                try
                {
                    stream.ReadByte();
                    return false;
                }
                catch (IOException)
                {
                    return true;
                }
                finally
                {
                    stream.Close();
                    stream.Dispose();
                }                        
            }
        }
        else
            return true;
    }
    catch (IOException)
    {
        return true;
    }
}